//
//  MacroUtility.h
//  CFFinanceProject
//
//  Created by chunfeng on 2018/4/9.
//  Copyright © 2018年 xiaowen. All rights reserved.
//
/**
 公共宏定义
 */

#ifndef MacroUtility_h
#define MacroUtility_h

#define DEF_WINDOW [UIApplication sharedApplication].keyWindow

#define Bit  [UIScreen mainScreen].bounds.size.width/375.0
//字符串去除空类
#define OKString(str)    [NSString getStringIsNotNull:str]
//字典绑定键值对
#define OKDicBind(...)   NSDictionaryOfVariableBindings(__VA_ARGS__)

#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)


/**
 *字体
 */
#define DEF_MyFont(x)     [UIFont systemFontOfSize:x]
#define DEF_MyBoldFont(x) [UIFont boldSystemFontOfSize:x]

/**
 *设置图片
 */
#define DEF_IMAGENAME(name)         [UIImage imageNamed:name]

/**
 *字符串去左右空格
 */
#define DEF_DROP_WHITESPACE(x) [x stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]


/**
 *获取AppDelegate
 */
#define DEF_MyAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)

/**
 *获取APP当前版本号
 */
#define DEF_AppCurrentVersion [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]


/**
 *获取APPbundleIdentifier
 */
#define DEF_App_BundleId [[NSBundle mainBundle] bundleIdentifier]
/**
 *Document路径
 */
#define DEF_DocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]

/**
 *NSUserDefault
 */
#define DEF_UserDefaults [NSUserDefaults standardUserDefaults]


//app常用功能
#define DEF_APP_NAME    [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
#define DEF_APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define DEF_APP_OS      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"DTPlatformVersion"]



/**
 *所有类型转化成String(防止出现nill值显示在UI)
 */
#define DEF_OBJECT_TO_STIRNG(object) ((object && object != (id)[NSNull null] && ([object isKindOfClass:[NSNumber class]] || ![object isEqualToString:@"<null>"]))?([object isKindOfClass:[NSString class]]?object:[NSString stringWithFormat:@"%@",object]):@"")



#undef    BLOCK_SAFE
#define BLOCK_SAFE(block)           if(block)block
////是否输出日志
#define __DEBUG_



#ifdef DEBUG
//#define NSLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
#define NSLog(...) printf("%f %s\n",[[NSDate date]timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);
#else
#define NSLog(format, ...)
#endif



#endif /* MacroUtility_h */
